<?php
/**
 * @filesource /modules/user/Form/Register.php
 * @abstract Generate a register form, where no lable is set
 *     see /modules/user/views/register/register.phtml for how the form is generated.
 */
class user_Form_Edit extends Zend_Form
{
    protected $_noDecorator = array(
        'ViewHelper', 
        'Errors'
    );

    public function cluBuild($params)
    {
        $user = new user_Model_User(); //for DbUnique validators
        $this->setMethod('POST');
        // set the method for the display form to POST
//        $actionEditForm = $params['view']->hvnUrl(array('module' => 'user', 'action'=>'edit-profile', 'controller' => 'account'));
//		$this->setAction($actionEditForm);

        $this->setAction($params['action_url']);
        
		//common filters & validators for all fields
        $filterTrim = new Zend_Filter_StringTrim();
        $filterHtmlBody = new Clu_Filter_HtmlBody();
        
        //no-special-character validator
        $nscValidator = new Zend_Validate_Regex('/^[,A-Z0-9_\s\-]*$/i'); //alpha, num, space, -, _
        $nscValidator->setMessage(t(60), Zend_Validate_Regex::NOT_MATCH);
                
        //no-special-character validator
        $addressValidator = new Zend_Validate_Regex('/^[A-Z0-9_\s\-\/\+;,]*$/i'); //alpha, num, space, -, _
        $addressValidator->setMessage(t(60), Zend_Validate_Regex::NOT_MATCH);
        
        //website Url
        $urlValidator = new Zend_Validate_Regex('/^[:A-Z0-9_\-\/\+\.\?]*$/i'); //alpha, num, space, -, _
        $urlValidator->setMessage(t(426), Zend_Validate_Regex::NOT_MATCH);
        
        //fone Validator
        $phoneValidator = new Zend_Validate_Regex('/^[;0-9_\s\-\+\(\)\.]*$/i'); //alpha, num, space, -, _
        $phoneValidator->setMessage(t(60), Zend_Validate_Regex::NOT_MATCH);
        
        $validatorNotEmpty = new Zend_Validate_NotEmpty();
        $validatorNotEmpty->setMessage(t(418));

		if($params['type'] == 2)
		{
			//Full name
	        $fullname = new Zend_Form_Element_Text('fullname', 
	                         array('disableLoadDefaultDecorators' => true,
	                               'class' => 'inputText'));
	        
	        $fullname->addDecorators($this->_noDecorator);
//	              ->addValidator($nscValidator);
	        $this->addElement($fullname);
	        
	        // gender
	        $gender = new Zend_Form_Element_Select('gender',  array('disableLoadDefaultDecorators' => true,
	                                                                 'required' => true));
	        $gender->addMultiOption('na','--'.t(97).'--')
	               ->addMultiOption('male',t(427))
	               ->addMultiOption('female',t(428))
	               ->addDecorators($this->_noDecorator);
	        $this->addElement($gender);
	        
	        //signature
	        $fck = new Clu_Form_Element_FckEditor('signature', array(
	        		'fckOptions' => array (
	        						'Height' => 100,
	        						'Width'  => 450,
	        						'ToolbarSet' => 'UserSignature'
	        					)
	       			 )
	        );
	        $fck->setLabel(t(429));
	        $fck->addFilter($filterHtmlBody ); //TODO: if our people, maybe we don't need to filter
	        $this->addElement($fck);
		}
		
		else if($params['type'] == 1)
		{
			//Company name
	        $company_name = new Zend_Form_Element_Text('company_name', 
	                         array('disableLoadDefaultDecorators' => true,
	                               'class' => 'inputText'));
	        
	        $company_name->addDecorators($this->_noDecorator);
//	              ->addValidator($nscValidator);
	        $this->addElement($company_name);
	        
	        //Company address
	        $company_address = new Zend_Form_Element_Text('company_address', 
	                         array('disableLoadDefaultDecorators' => true,
	                               'class' => 'inputText'));
	        
	        $company_address->addDecorators($this->_noDecorator);
	              //->addValidator($addressValidator);
	        $this->addElement($company_address);
	        
	        //company description
			$fckDes = new Clu_Form_Element_FckEditor('company_description', array(
	        		'fckOptions' => array (
	        						'Height' => 100,
	        						'Width'  => 450,
	        						'ToolbarSet' => 'UserSignature'
	        					)
	       			 )
	        );
	        $fckDes->setLabel(t(429));
	        $fckDes->addFilter($filterHtmlBody ); //TODO: if our people, maybe we don't need to filter
	        $this->addElement($fckDes);
	        
	        //fax
	        $fax = new Zend_Form_Element_Text('fax', 
	                         array('disableLoadDefaultDecorators' => true,
	                               'class' => 'inputText'));
	        
	        $fax->addDecorators($this->_noDecorator)
	              ->addValidator($phoneValidator);
	        $this->addElement($fax);
		}
		
        //Default Language
        $language = new Zend_Form_Element_Select('language',  array('disableLoadDefaultDecorators' => true,
                                                                 'required' => true));
        foreach (Zend_Registry::get('configuration')->languagename as $k=>$v)
	        $language->addMultiOption($k,p($v));
        $language->addDecorators($this->_noDecorator);
        $this->addElement($language);
        
        //Full name
        $website = new Zend_Form_Element_Text('website', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        
        $website->addDecorators($this->_noDecorator)
              ->addValidator($urlValidator);
        $this->addElement($website);
        
//        $signature = new Clu_Form_Element_FckEditor('signature');
//        $signature->setLabel('signature')
//            	  ->addFilter($filterHtmlBody );
//        
//        $this->addElement($signature);
        
//        //preferred theme
//        $theme = new Zend_Form_Element_Select('theme',  array('disableLoadDefaultDecorators' => true,
//                                                                 'required' => true));
//        foreach (explode (' ',Zend_Registry::get('configuration')->themes) as $v)
//	        $theme->addMultiOption($v, $v);
//        $theme->addDecorators($this->_noDecorator);
//        $this->addElement($theme);
        

        //phone 1
        $phone = new Zend_Form_Element_Text('phone', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        
        $phone->addDecorators($this->_noDecorator)
              ->addValidator($phoneValidator);
        $this->addElement($phone);
        
        
        //address 1
        $address = new Zend_Form_Element_Text('address', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        
        $address->addDecorators($this->_noDecorator);
//              ->addValidator($addressValidator);
        $this->addElement($address);
        
        /*
        //Country
        $fullname = new Zend_Form_Element_Text('fullname', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        
        $fullname->addDecorators($this->_noDecorator)
              ->addValidator($nscValidator);
        $this->addElement($fullname);
        
        //Timezone
        $fullname = new Zend_Form_Element_Text('fullname', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        
        $fullname->addDecorators($this->_noDecorator)
              ->addValidator($nscValidator);
        $this->addElement($fullname);
        */
        //submit
        // add the submit button
        $submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true, 
                                                               'label' => t(59) ));
        $submit->addDecorators($this->_noDecorator);
        $this->addElement($submit);

    }
}

?>